package com.leo.anywhereimageview;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.CardView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

import com.bumptech.glide.Glide;

public class MyViewActivity extends AppCompatActivity {
    CardView cardview;
    ExpLayout ExpLayout;

    CardView cardview2;
    ExpLayout ExpLayout2;

    CardView cardview3;
    ExpLayout ExpLayout3;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_myview);
        cardview = (CardView) findViewById(R.id.cardview);
        ExpLayout = (com.leo.anywhereimageview.ExpLayout) findViewById(R.id.ExpLayout);

        cardview2 = (CardView) findViewById(R.id.cardview2);
        ExpLayout2 = (com.leo.anywhereimageview.ExpLayout) findViewById(R.id.ExpLayout2);


        cardview3 = (CardView) findViewById(R.id.cardview3);
        ExpLayout3 = (com.leo.anywhereimageview.ExpLayout) findViewById(R.id.ExpLayout3);


        //只给图片原始宽高  不给显示区域坐标
        //设置控件大小宽漫屏，高度宽16:9
        LinearLayout.LayoutParams reParams = (LinearLayout.LayoutParams) cardview.getLayoutParams();
        reParams.height = UIUtil.getWidth(this) * 9 / 16;

        FrameLayout.LayoutParams exParams = (FrameLayout.LayoutParams) ExpLayout.getLayoutParams();
        exParams.height = UIUtil.getWidth(this) * 9 / 16;
        exParams.width = UIUtil.getWidth(this);
        ExpLayout.setImgBg(580, 773, R.drawable.play_region_bg);


        //给显示控件 上半部分的点坐标。即 自定义view point_y在上面。则图片无需移动，显示区域从，图片0,0开始
        //因为写例子原图片我取好了，这里的x坐标用不到。先忽略
        LinearLayout.LayoutParams reParams2 = (LinearLayout.LayoutParams) cardview2.getLayoutParams();
        reParams2.height = UIUtil.getWidth(this) * 9 / 16;

        FrameLayout.LayoutParams exParams2 = (FrameLayout.LayoutParams) ExpLayout2.getLayoutParams();
        exParams2.height = UIUtil.getWidth(this) * 9 / 16;
        exParams2.width = UIUtil.getWidth(this);
        ExpLayout2.setImgBg(580, 773, R.drawable.play_region_bg, 0, 0, 0, 10);

        findViewById(R.id.text_move).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                ExpLayout2.move();

            }
        });


        //要显示的区域不可见了  那么我们要对其移动，代码见ExpLayout里的逻辑
        LinearLayout.LayoutParams reParams3 = (LinearLayout.LayoutParams) cardview3.getLayoutParams();
        reParams3.height = UIUtil.getWidth(this) * 9 / 16;

        FrameLayout.LayoutParams exParams3 = (FrameLayout.LayoutParams) ExpLayout3.getLayoutParams();
        exParams3.height = UIUtil.getWidth(this) * 9 / 16;
        exParams3.width = UIUtil.getWidth(this);
        ExpLayout3.setImgBg(580, 773, R.drawable.play_region_bg, 0, 1900, 0,1919 );

    }
}
